<?php
namespace app\common\request\tysj;

class Product extends Base {
	public function list() {
		$uid = $this->get_current_uid();
		$sid = $this->post('sid');
		$commission = $this->post('commission');
		$cid = $this->post('cid');
		$price = $this->post('price');
		$search = $this->post('search');
		$specs_list = $this->post('specs_list');
		$list_type = $this->post('list_type');
		$type = $this->post('type', 'sale');
		$limit = $this->param('limit');
		$is_group_buying = $this->post('is_group_buying');
		$area_id = $this->post('area_id');
		return compact('uid', 'sid', 'commission', 'cid', 'price', 'search', 'specs_list', 'list_type', 'type', 'limit', 'is_group_buying', 'area_id');
	}

	public function private_list() {  
		$uid = $this->get_current_uid();
		$sid = $this->post('sid');
		$commission = $this->post('commission');
		$cid = $this->post('cid');
		$price = $this->post('price');
		$search = $this->post('search');
		$specs_list = $this->post('specs_list');
		$list_type = $this->post('list_type');
		$type = $this->post('type');
		$limit = $this->param('limit');
		$is_group_buying = $this->post('is_group_buying');
		$area_id = $this->post('area_id');
		return compact('uid', 'sid', 'commission', 'cid', 'price', 'search', 'specs_list', 'list_type', 'type', 'limit', 'is_group_buying', 'area_id');
	}

	public function save_data() {
		$id                    = $this->param('id');
		$sid                   = $this->post('sid');
		$photo                 = $this->post('photo');	
		$photos                = $this->post_collection('photos', true);
		$name                  = $this->post('name');
		$selling               = $this->post('selling');
		$cid                   = $this->post('cid');
		$osid                  = $this->post('osid');
		$specs                 = $this->post_collection('specs', true);
		$info_photo            = $this->post_collection('info_photo', true);
		$examine_after_status  = $this->post('examine_after_status', 0);
		$area_id                = $this->post('area_id');
		$is_group_buying       = $this->post('is_group_buying');

		if(!$photo && count($photos) > 0) {
			$photo = $photos[0];
		}
		return compact('id', 'sid', 'photo', 'photos', 'name', 'selling', 'cid', 'osid', 'specs', 'info_photo', 'examine_after_status', 'area_id', 'is_group_buying');
	}
}
